var signUpButton = document.getElementById('signUp');
var signInButton = document.getElementById('signIn');
var container = document.getElementById('dowebok');
var $_GET = (function () {
    var url = window.document.location.href.toString();
    var u = url.split("?");
    if (typeof (u[1]) == "string") {
        u = u[1].split("&");
        var get = {};
        for (var i in u) {
            var j = u[i].split("=");
            get[j[0]] = j[1];
        }
        return get;
    } else {
        return {};
    }
})();
signUpButton.addEventListener('click', function () {
    container.classList.add('right-panel-active')
});
signInButton.addEventListener('click', function () {
    container.classList.remove('right-panel-active')
});

$(function () {
    let login_type = $_GET["type"] ? $_GET["type"] : "login";
    switch (login_type){
        case "login":
            container.classList.remove('right-panel-active')
            break;
        case "logon":
            container.classList.add('right-panel-active')
            break;
    }
})

//下面
//是
//自己写的部分
let baseURL = 'https://exam.youmengxinxi.com:10021'
$(function (){
    $('#login_ing').click(function (){
        let password = $("#password").val();
        let userName = $("#userName").val();
        $.ajax({
            url:baseURL +'/login/api/sys/login',
            type:'post',
            data:{
                password:password,
                userName:userName
            },
            success:function (c){
                let data = c.data;
                let school_name = (data.name);
                let user_name = (data.username);
                let login_type = (c.code);
                let authorities =(c.msg);
                if (login_type === 1){
                    $.session.set('log_type', login_type)
                    $.session.set('userName', userName)
                    $.session.set('password', password)
                    $.session.set('school_name', school_name)
                    $.session.set('user_name', user_name)
                    $.session.set('authorities', authorities)
                    location.href="studentmange.html";
                }
                else if (login_type !== 1){
                    alert("账号或密码错误")
                    //下面这个仅供测试用
                    // location.href="studentmange.html";
                    //
                }
            }
        })
    })
})
